import java.io.*;//异常报错
import java.net.*;//服务器套接字

public class Sever2 {
    public static void main(String[] args) throws IOException {
        ServerSocket sv=new ServerSocket(12346);
        while(true){
            Socket sk=sv.accept();
            InputStream in=sk.getInputStream();
            OutputStream out= sk.getOutputStream();

            InputStreamReader ir=new InputStreamReader(in);
            OutputStreamWriter ow=new OutputStreamWriter(out);

            BufferedReader br=new BufferedReader(ir);
            BufferedWriter bw=new BufferedWriter(ow);

            InputStreamReader ik=new InputStreamReader(System.in);
            BufferedReader kr=new BufferedReader(ik);

            String s1,s2;
            do{
                s1=br.readLine();
                System.out.println("对方说： "+s1);

                System.out.print("我说：  ");
                s2=kr.readLine();
                bw.write(s2);
                bw.newLine();
                bw.flush();
            }while(!s1.equals("Bye"));
            sk.close();
        }
    }
}
